home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Amiga-E
/
E_v3.2a
/
Src
/
Tools
/
qItemAddress
/
test.e
< prev
Wrap
Text File
|
1994-12-08
|
5KB
|
169 lines
/*----------------------------------------------------------*
Demo of qualifiedItemAddress module.
E Source generated by SRCGEN v0.1
CHANGES TO ORIGINAL GEN'ED CODE:
- inclusion of module 'other/qualifiedItemAddress'
- localization of some global variables to the functions
wait4message() and main()
- restructured wait4message() to return multiple values
when a IDCMP_MENUPICK message is received
- restructured main() to process (correctly) multiply
selected menu items in a single event
- minor changes to the CreateMenusA() arguments
Source modified by B. Wills, Dec 12, 1994.
Placed in public domain.
*----------------------------------------------------------*/
OPT OSVERSION=37
OPT REG=5
MODULE 'gadtools',
'libraries/gadtools',
'intuition/intuition',
'intuition/screens',
'intuition/gadgetclass',
'graphics/text'
MODULE 'other/qualifiedItemAddress'
ENUM NONE,NOCONTEXT,NOGADGET,NOWB,NOVISUAL,OPENGT,NOWINDOW,NOMENUS
DEF project0wnd:PTR TO window,
project0menus,
project0glist,
scr:PTR TO screen,
visual=NIL,
offx,offy,tattr
PROC setupscreen()
IF (gadtoolsbase:=OpenLibrary('gadtools.library',37))=NIL THEN RETURN OPENGT
IF (scr:=LockPubScreen('Workbench'))=NIL THEN RETURN NOWB
IF (visual:=GetVisualInfoA(scr,NIL))=NIL THEN RETURN NOVISUAL
offy:=scr.wbortop+Int(scr.rastport+58)-10
tattr:=['topaz.font',8,0,0]:textattr
ENDPROC
PROC closedownscreen()
IF visual THEN FreeVisualInfo(visual)
IF scr THEN UnlockPubScreen(NIL,scr)
IF gadtoolsbase THEN CloseLibrary(gadtoolsbase)
ENDPROC
PROC openproject0window()
DEF g:PTR TO gadget
IF (g:=CreateContext({project0glist}))=NIL THEN RETURN NOCONTEXT
IF (project0menus:=
CreateMenusA([1,0,'M1',0,$0,0,0,
2,0,'I1', 'a',$0,0,0,
2,0,'I2', 'A',$0,0,0,
2,0,'I3', NIL,$0,0,0,
3,0,'I3.1', 'b',$0,0,0,
3,0,'I3.2', 'B',$0,0,0,
2,0,'I4', NIL,$0,0,0,
3,0,'I4.1', 'C',$0,0,0,
3,0,'I4.2', 'c',$0,0,0,
1,0,'M2', NIL,$0,0,0,
2,0,'I1', 'd',$0,0,0,
2,0,'I2', 'E',$0,0,0,
2,0,'I3', NIL,$0,0,0,
3,0,'I3.1', 'D',$0,0,0,
3,0,'I3.2', 'e',$0,0,0,
2,0,'I4', 'f',$0,0,0,
2,0,'I5', 'G',$0,0,0,
0,0,0,0,0,0,0]:newmenu,NIL))=NIL THEN RETURN NOMENUS
IF LayoutMenusA(project0menus,visual,NIL)=FALSE THEN RETURN NOMENUS
IF (project0wnd:=OpenWindowTagList(NIL,
[WA_LEFT,10,
WA_TOP,15,
WA_WIDTH,offx+400,
WA_HEIGHT,offy+89,
WA_IDCMP,$24C077E,
WA_FLAGS,$100F,
WA_TITLE,'Try Hotkeys AND Mouse',
WA_CUSTOMSCREEN,scr,
WA_MINWIDTH,67,
WA_MINHEIGHT,21,
WA_MAXWIDTH,$2C0,
WA_MAXHEIGHT,$226,
WA_AUTOADJUST,1,
WA_AUTOADJUST,1,
NIL]))=NIL THEN RETURN NOWINDOW
IF SetMenuStrip(project0wnd,project0menus)=FALSE THEN RETURN NOMENUS
Gt_RefreshWindow(project0wnd,NIL)
SetStdRast(project0wnd.rport)
Colour(1)
ENDPROC
PROC closeproject0window()
IF project0wnd THEN ClearMenuStrip(project0wnd)
IF project0menus THEN FreeMenus(project0menus)
IF project0wnd THEN CloseWindow(project0wnd)
IF project0glist THEN FreeGadgets(project0glist)
ENDPROC
PROC reporterr(er)
DEF erlist:PTR TO LONG
IF er
erlist:=['get context','create gadget','lock wb','get visual infos',
'open "gadtools.library" v37+','open window','create menus']
EasyRequestArgs(0,[20,0,0,'Could not \s!','ok'],0,[erlist[er-1]])
ENDIF
ENDPROC er
PROC wait4message(win:PTR TO window)
DEF mes:PTR TO intuimessage, class, code, qualifier
REPEAT
class:=0
IF mes:=Gt_GetIMsg(win.userport)
class:=mes.class
IF class=IDCMP_MENUPICK
code:=mes.code
qualifier:=mes.qualifier
ELSEIF (class=IDCMP_GADGETDOWN) OR (class=IDCMP_GADGETUP)
code:=mes.iaddress
ELSEIF class=IDCMP_REFRESHWINDOW
Gt_BeginRefresh(win)
Gt_EndRefresh(win,TRUE)
class:=0
ELSEIF class<>IDCMP_CLOSEWINDOW /* remove these if you like */
class:=0
ENDIF
Gt_ReplyIMsg(mes)
ELSE
WaitPort(win.userport)
ENDIF
UNTIL class
ENDPROC class,code,qualifier
PROC main()
DEF done=FALSE, class, code, qualifier, iaddress=NIL:PTR TO menuitem
IF reporterr(setupscreen())=0
reporterr(openproject0window())
REPEAT
class,code,qualifier:=wait4message(project0wnd)
SELECT class
CASE IDCMP_CLOSEWINDOW
done:=TRUE
CASE IDCMP_MENUPICK
WHILE code<>-1 ->MENUNULL doesn't work since
-> terminal nextselect is -1 in E, vice 65535 in C.
IF iaddress:=qualifiedItemAddress(project0menus, code, qualifier)
TextF(4, 30, 'MenuId=\d Char=\c Qual=$\h ',
code, iaddress.command, qualifier)
code:=iaddress.nextselect
Delay(50) ->allow time to read the menu info
ELSE
code:=-1
ENDIF
IF CtrlC() THEN code:=-1
ENDWHILE
ENDSELECT
UNTIL done
closeproject0window()
ENDIF
closedownscreen()
ENDPROC